package com.springboot.demo.entity;

import com.springboot.demo.entity.validate.NameGroup;
import com.springboot.demo.entity.validate.SceneIdGroup;
import com.springboot.demo.entity.validate.scene.SceneNameGroup;
import com.springboot.demo.entity.validate.user.IdGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @author wubc683
 * @desc
 * @date 2021-10-13 11:32
 */
@Data
public class Connection {
    @ApiModelProperty(value = "连接id",required = true)
    @NotNull(message= "连接id不能为null",groups = IdGroup.class)
    private Long id;
    @ApiModelProperty(value = "连接序号",required = true)
    @NotNull(message= "连接序号不能为null")
    @Min(value = 0,message = "连接序号最小值为0")
    @Max(value = 10000, message = "连接序号最大值为10000")
    private Integer connectNo;
    @ApiModelProperty(value = "场景id",required = true)
    @NotNull(message = "场景id不能为null",groups = SceneIdGroup.class)
    private Long sceneId;
    @ApiModelProperty(value = "连接名称",required = true)
    @NotBlank(message= "连接名称不能为null或者空")
    @Length(max=32,message = "连接名称太长")
    @Pattern(regexp = "^[\\u4E00-\\u9FA5a-zA-Z0-9_-]{1,32}$", message = "连接名格式错误")
    private String name;
    @ApiModelProperty(value = "通信驱动程序",required = true)
    @NotNull(message = "驱动程序不能为null")
    private Integer driveType;
    @ApiModelProperty(value = "接口",required = true)
    @NotBlank(message = "连接接口不能为null或者空")
    private String port;
}
